<?php
namespace app\backend\model;
class Response
{
    private $code = RESPONSE_ERROR;
    var $msg = null;
    var $data = null;

    public function fail() {
        $this->code = RESPONSE_ERROR;
    }

    public function success() {
        $this->code = RESPONSE_OK;
    }

    public function toJson() {
        $arr = [
            "code" => $this->code,
            "msg" => $this->msg,
            "data" => $this->data
        ];
        return json_encode($arr);
    }
}